package com.isnmp.nms.framework.discover;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import com.isnmp.common.snmp.mib.Dot1dBasePortEntry;
import com.isnmp.common.snmp.mib.MibIfEntry;

public class PortInfo implements Serializable {
    public DeviceInfo device;
    public int port = -1;
    public boolean isUseIfIndexPort = false;
    public List<String> portMacList = new ArrayList();
    public List<DeviceInfo> subDeviceList = new Vector();

    public String toString() {
        return this.device + Messages.getString("PortInfo.0") + this.port;
    }

    public MibIfEntry getPortMibIfEntry() {
        int i = -2147483648;
        Object localObject;
        if (this.isUseIfIndexPort) {
            i = this.port;
        } else {
            Iterator localIterator = this.device.getBasePortList().iterator();
            while (localIterator.hasNext()) {
                localObject = (Dot1dBasePortEntry) localIterator.next();
                if (((Dot1dBasePortEntry) localObject).getDot1dBasePort() == this.port)
                    i = ((Dot1dBasePortEntry) localObject).getDot1dBasePortIfIndex();
            }
        }
        Iterator localIterator = this.device.getIfTableList().iterator();
        while (localIterator.hasNext()) {
            localObject = (MibIfEntry) localIterator.next();
            if (((MibIfEntry) localObject).getIfIndex() == i)
                return (MibIfEntry) localObject;
        }
        return null;
    }

    public int hashCode() {
        int i = 1;
        i = 31 * i + (this.device == null ? 0 : this.device.hashCode());
        i = 31 * i + this.port;
        return i;
    }

    public boolean equals(Object paramObject) {
        if (this == paramObject)
            return true;
        if (paramObject == null)
            return false;
        if (!(paramObject instanceof PortInfo))
            return false;
        PortInfo localPortInfo = (PortInfo) paramObject;
        if (this.device == null) {
            if (localPortInfo.device != null)
                return false;
        } else if (!this.device.equals(localPortInfo.device))
            return false;
        return this.port == localPortInfo.port;
    }
}